package ar.edu.itba.it.pdc.configuration.models.filters.destinyFilters;

import java.util.regex.Pattern;

import ar.edu.itba.it.pdc.configuration.models.Request;
import ar.edu.itba.it.pdc.monitoring.ProxyMonitoring;

public class DestinyURIFilter extends DestinyFilter{
	
	private String URI;
	
	public DestinyURIFilter(String URI) {
		this.URI = URI;
		setApplyOnRequest(true);
		setApplyOnResponse(false);
	}
	
	@Override
	public boolean applyFilterOnRequest(Request req) {
		if (!Pattern.matches(this.URI, req.getURI())) {
			return true;
		}
		ProxyMonitoring.getInstance().addURIBlock();
		return false;
	}
	
	@Override
	public String getContent() {
		return URI;
	}
	
	@Override
	public String getCriteria() {
		return "URI Pattern";
	}
	
}
